shr.defineClass("shr.behavior.userbehavior", shr.framework.Core, {
	 init: function () {
		var failture = window.sessionStorage.getItem("userBehaviorFailture");
		if(failture==null || failture=='undefined'){
			window.sessionStorage.setItem('userBehaviorFailture','0');
		}else{
			if(parseInt(failture) >=3){ //connection failture 3 times 
				return ;
			}
		}
		var config = new Object() ;
		var value = window.sessionStorage.getItem("FProductRegNO");
		if(value=='undefined' || value==null){
				var ajaxData = shr.callService({
				serviceName: "getLicenseInfo",
				async:false
			 });
			 value = ajaxData.serialNum;
			 if(value=='undefined' || value==null){
				return ;
			 }else{
				window.sessionStorage.setItem('FProductRegNO', value);	
				window.sessionStorage.setItem('FAccountName', ajaxData.FAccountName);	
				window.sessionStorage.setItem('FProductVer', ajaxData.version);	
			 }
		}
		config.FProductRegNO=value;
		config.FProductID='S10S001S002';
		config.FProductVer=window.sessionStorage.getItem('FProductVer');
		config.FAccountName=window.sessionStorage.getItem('FAccountName');
		config.FAdditionalInfo='0';
		var FOperationDays = new Object();
		var str = "";
		try {
			str=waf.datepicker.formatDate("yymmdd",new Date());
		} catch(error) {
			var now = new Date(), year = now.getFullYear(),
				tmpMonth = 1 + now.getMonth(), month = (tmpMonth < 10) ? ("0" + tmpMonth) : tmpMonth,
				day = now.getDate();
			str = year + month + day;
		}
		FOperationDays.FOperationDay=str;
		var FFunctions = new Object();
		var user = shr.getUserInfo();
		config.FAccountUser=encodeURIComponent(user.id);
		var page = shr.getPageInfo();
		var key = page.page_code;
		if(page.page_code == null || page.page_code=='undefined'){
			key =page.category_desc+"-"+page.page_desc;
		}
		if(key == 'blank'){
		  key =key+page.category_desc+"-"+page.page_desc;
		}
		FFunctions.FFunctionKey=key;
		//FFunctions.FFunctionValue=
		FFunctions.FOperationCount='1';
		FOperationDays.FFunctions=[FFunctions];
		config.FOperationDays=[FOperationDays];
		this.saveuserBehavior(config);
	},

	saveuserBehavior :function (config){
		var dataparam = new Object();
		dataparam.guid=((new Date()).getUTCMilliseconds()).toString();
		dataparam.text=config;
		try{
			var url ='http://patch.cmcloud.cn/log.do?guid=3000000001'+'&text='+$.toJSON(config)+'&format=jsonp';
			$.ajax({
				url:url,
				timeout: 1000,				
				dataType:"jsonp",
				async:true,
				error:function(data){
					var value = parseInt(window.sessionStorage.getItem("userBehaviorFailture"));
					value = value+1;
					window.sessionStorage.setItem("userBehaviorFailture",value.toString());
				},
				success:function(data){
					var value = data;
				}
			});
		}catch(e){
		}
	}

});